package com.dragon.refect.field;

import java.lang.reflect.Field;
import java.util.Arrays;

/**
 * @author dragon
 * @since 2019/12/2
 */
public class FieldTest2 {

    public static void main(String[] args) throws Exception{
        Class<Dog> dogClass = Dog.class;
        Dog dog = dogClass.newInstance();

        Field[] fields = dogClass.getFields();
        System.out.println(Arrays.toString(fields));
        System.out.println("==============================");
        Field[] declaredFields = dogClass.getDeclaredFields();
        System.out.println(Arrays.toString(declaredFields));
        System.out.println("==============================");
        for (Field declaredField : declaredFields) {
            System.out.println("name: " + declaredField.getName()+" modifier: " + declaredField.getModifiers() +" type: "
            + declaredField.getType() + " declaredClass: " + declaredField.getDeclaringClass());
        }
    }
}
